package com.yanqu.road.server.manager.union.unionrank;

import com.yanqu.road.pb.rank.RankProto;
import com.yanqu.road.utils.date.DateHelper;

public class CrossUnionRankCache {
    private int keyId; //活动id 或者 组id
    private long lastRankTime;
    private int rankNum;
    private RankProto.UnionRankListMsg rankMsg;


    public CrossUnionRankCache(int keyId, int rankNum) {
        this.keyId = keyId;
        this.rankNum = rankNum;
        this.rankMsg = RankProto.UnionRankListMsg.newBuilder().build();
    }




    public int getKeyId() {
        return keyId;
    }

    public long getLastRankTime() {
        return lastRankTime;
    }

    public int getRankNum() {
        return rankNum;
    }

    public RankProto.UnionRankListMsg getRankMsg() {
        return rankMsg;
    }

    public boolean isNeedUpdateRank(long checkSecond) {
        long currentTime = DateHelper.getCurrentTime();
        if (currentTime - lastRankTime > checkSecond * DateHelper.SECOND_MILLIONS) {
            return true;
        }
        return false;
    }

    public void setRankMsg(RankProto.UnionRankListMsg saveRankBuilder) {
        this.rankMsg = saveRankBuilder;
        this.lastRankTime = DateHelper.getCurrentTime();
    }

    public void setRankNum(int rankNum) {
        this.rankNum = rankNum;
    }
}
